Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming
THIS-OBJECT system reference
THIS-OBJECTis a system reference available from within a class definition. At run time, it returns the currently running instance of the class as an object reference. Its most important purpose is to allow a method of the class to pass a reference to the currently instantiated object as a parameter or to return a reference to itself as a method return value.The following example shows a class,
acme.myObjs.NewCustomer, that inherits from the sample classacme.myObjs.CustObj. This is not one of the documented sample classes, but is created to illustrate a use of theTHIS-OBJECTsystem reference. A call to itssetNewCustObj( )method passes an object reference to the current instance of itself (THIS-OBJECT) to theListDate( )method of the sample classacme.myObjs.Common.HelperClass, which timestamps itself and displays the resultingtimestampvalue, as shown:
Because the
THIS-OBJECTinput parameter also represents a subclass of the sample classacme.myObjs.Common.CommonObj, theListDate( )method can invoke theupdateTimestamp( )method on the parameter object reference (rObject) to timestamp the object, whichTHIS-OBJECTcan, in turn, reference whenListDate( )returns, as previously:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |